
import fs from 'fs';
import path from 'path';

export default async (req, res) => {
    try {

        const BLOG_DIR = process.env.BLOG_DIR
        const filePath = path.join(BLOG_DIR, ".zettelkasten")

        const data = fs.readFileSync(filePath, 'utf8');

        res.status(200).json( JSON.parse(data));
    } catch (error) {
        res.status(error.response?.status || 500).json({ error: error.message });
    }
  };